package com.sky.service.impl;

import com.sky.result.Result;
import com.sky.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class ShopServiceImpl implements ShopService {
    public  static final String KEY="SHOP_STATUS";
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * 设置店铺的营业状态
     * @param status
     * @return
     */
    @Override
    public Result setStatus(Integer status) {

        redisTemplate.opsForValue().set(KEY,status.toString());
        return Result.success();
    }

    /**
     * 获取店铺的营业状态
     *
     * @return
     */
    @Override
    public Result getStatus() {

        String status = redisTemplate.opsForValue().get(KEY);
        return Result.success(Integer.parseInt(status));
    }
}
